<?php

// Define path to application directory
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));

defined('DATA_PATH')
	|| define('DATA_PATH', str_replace('application', 'data', APPLICATION_PATH));

$settings = parse_ini_file(APPLICATION_PATH . '/configs/settings.ini');
$environment = array_search($_SERVER['HTTP_HOST'], $settings);

if (FALSE === $environment) {
	echo 'Existe un problema con la configuraci&oacute;n de su m&aacute;quina, contacte con el administrador';
	exit;
}

// Define application environment
defined('APPLICATION_ENV')
    || define('APPLICATION_ENV', $environment);

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library'),
    get_include_path(),
)));


/** Zend_Application */
if ($_SERVER['REQUEST_URI'] !== '/') {
    require_once 'Zend/Application.php';

    // Create application, bootstrap, and run
    $application = new Zend_Application(
        APPLICATION_ENV,
        APPLICATION_PATH . '/configs/application.ini'
    );

    $application->bootstrap()
                ->run();

    exit;
}

// Mandar header de compatibilidad
$navegador = get_browser($_SERVER['HTTP_USER_AGENT']);
if ('IE' == $navegador->browser) {
	header('X-UA-Compatible: IE=edge,chrome=1');
}

echo <<<HTML
<!doctype html>
<html>
    <head>
        <meta charset="UTF-8">
        <link rel="stylesheet" type="text/css" href="css/app.css">
    </head>
    <body>
        <script src="js/app.js"></script>
    </body>
</html>
HTML;
